<template>
	<view class="page" :style="{height: $u.sys().windowHeight + 'px'}">
		<view class="container">
			<view class="logo">LOGO</view>
			<view class="form">
				<u-form :model="form" :rules="rules" ref="form">
					<u-form-item prop="phone">
						<u-input v-model="form.phone" type="number" :placeholder="$t('member.login.phone')"
							border="bottom"></u-input>
					</u-form-item>
					<u-form-item prop="pwd">
						<u-input v-if="!isShowPwd" v-model="form.pwd" type="password" :placeholder="$t('member.login.pwd')"
							border="bottom">
							<template slot="suffix">
								<u-icon name="eye-off" color="#B9BFCB" @click="showPwd"></u-icon>
							</template>
						</u-input>
						<u-input v-else v-model="form.pwd" type="text" :placeholder="$t('member.login.pwd')" border="bottom">
							<template slot="suffix">
								<u-icon name="eye-fill" color="#B9BFCB" @click="showPwd"></u-icon>
							</template>
						</u-input>
						</u-form-item>
				</u-form>
			</view>
			<view class="forgot">
				<text @click="forgot">{{$t('member.login.forgot')}}</text>
			</view>
			<view class="submit">
				<u-button :loading="loading" class="btn" :text="$t('member.login.sumbit')" @click="login"></u-button>
			</view>
			<view class="change">
				<text @click="goReg">{{$t('member.go-reg')}}</text>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				form: {
					phone: '',
					pwd: ''
				},
				rules: {
					phone: {
						type: 'number',
						required: true,
						message: this.$t('member.login.phone')
					},
					pwd: {
						type: 'string',
						required: true,
						message: this.$t('member.login.pwd')
					},
				},
				isShowPwd: false,
				loading: false
			}
		},
		methods: {
			showPwd() {
				this.isShowPwd = !this.isShowPwd
			},
			login() {
				this.$refs.form.validate().then(res => {
					this.loading = true
					setTimeout(() => {
						uni.switchTab({
							url: '/pages/index'
						})
					}, 1000)
				})
			},
			forgot() {
				uni.navigateTo({
					url: '/pages/member/forgot-pwd'
				})
			},
			goReg() {
				uni.navigateTo({
					url: '/pages/member/register'
				})
			}
		}
	}
</script>
<style lang="scss">
	.page {
		background-color: #F5F5E8;
	}

	.container {
		width: calc(100% - 112rpx);
		margin: 0 24rpx;
		border-radius: 32rpx;
		background-color: #fff;
		padding: 32rpx;
		display: inline-flex;
		margin-top: 324rpx;
		flex-flow: column;
		align-items: center;

		.logo {
			display: flex;
			justify-content: center;
			width: 160rpx;
			height: 160rpx;
			border-radius: 32rpx;
			background-color: #033787;
			position: relative;
			top: -112rpx;
			color: #fff;
			font-size: 40rpx;
			align-items: center;
		}

		.form {
			width: 100%;
			margin-top: -80rpx;
		}

		.forgot {
			width: 100%;
			text-align: right;
			font-size: 24rpx;
			color: #7C8493;
		}

		.submit {
			margin-top: 72rpx;
			width: 100%;
			font-weight: 600;

			.btn {
				color: #ffffff;
				height: 96rpx;
				border-radius: 48rpx;
				background-color: #033787;
				border: none;
			}
		}

		.change {
			margin-top: 43rpx;
			font-size: 26rpx;
			color: #033787;
			font-weight: 600;
		}
	}
</style>